<form #form (ngSubmit)="submit()" [appApiAction]="formPromise">
    <header>
        <div class="left">
            <button type="button" appBlurClick (click)="cancel()">{{'cancel' | i18n}}</button>
        </div>
        <div class="center">
            <span class="title">{{'share' | i18n}}</span>
        </div>
        <div class="right">
            <button type="submit" appBlurClick [disabled]="form.loading || !canSave"
                *ngIf="organizations && organizations.length">
                <span [hidden]="form.loading">{{'save' | i18n}}</span>
                <i class="fa fa-spinner fa-lg fa-spin" [hidden]="!form.loading" aria-hidden="true"></i>
            </button>
        </div>
    </header>
    <content>
        <div class="box">
            <div class="box-content" *ngIf="!organizations || !organizations.length">
                <div class="box-content-row padded no-hover">
                    {{'noOrganizationsList' | i18n}}
                </div>
            </div>
            <div class="box-content" *ngIf="organizations && organizations.length">
                <div class="box-content-row" appBoxRow>
                    <label for="organization">{{'organization' | i18n}}</label>
                    <select id="organization" name="OrganizationId" [(ngModel)]="organizationId"
                        (change)="filterCollections()">
                        <option *ngFor="let o of organizations" [ngValue]="o.id">{{o.name}}</option>
                    </select>
                </div>
            </div>
            <div class="box-footer">
                {{'shareDesc' | i18n}}
            </div>
        </div>
        <div class="box" *ngIf="organizations && organizations.length">
            <div class="box-header">
                {{'collections' | i18n}}
            </div>
            <div class="box-content" *ngIf="!collections || !collections.length">
                <div class="box-content-row padded no-hover">
                    {{'noCollectionsInList' | i18n}}
                </div>
            </div>
            <div class="box-content" *ngIf="collections && collections.length">
                <div class="box-content-row box-content-row-checkbox" *ngFor="let c of collections; let i = index"
                    appBoxRow>
                    <label for="collection_{{i}}">{{c.name}}</label>
                    <input id="collection_{{i}}" type="checkbox" [(ngModel)]="c.checked"
                        name="Collection[{{i}}].Checked">
                </div>
            </div>
        </div>
    </content>
</form>
